package com.example.sys.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.sys.entity.Config;
import com.example.sys.entity.Notice;
import com.example.sys.mapper.NoticeMapper;
import com.example.sys.service.NoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.sys.vo.NoticeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 通知公告表 服务实现类
 * </p>
 *
 * @author anan
 * @since 2019-06-20
 */
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements NoticeService {

    @Autowired
    private NoticeMapper noticeMapper;

    @Override
    public IPage<Notice> selectPage(NoticeVo noticeVo) {
        IPage<Notice> iPage = new Page<>(noticeVo.getPage(), noticeVo.getLimit());
        QueryWrapper<Notice> wrapper = new QueryWrapper<>();
        if (!StrUtil.hasEmpty(noticeVo.getNoticeTitle()))
            wrapper.like("notice_title", noticeVo.getNoticeTitle());
        if (!StrUtil.hasEmpty(noticeVo.getCreateBy()))
            wrapper.like("create_by", noticeVo.getCreateBy());
        if (!StrUtil.hasEmpty(noticeVo.getStatus()))
            wrapper.like("status", noticeVo.getStatus());
        return noticeMapper.selectPage(iPage, wrapper);
    }
}
